<?php
namespace app\index\controller;

use think\Config;
use think\Request;

class Index
{
    public function index()
    {
        
    }

    public function info($id,$name)
    {
        return "{$id},{$name}";

    }

    public function req(Request $request)
    {
        #浏览器输入框的值
        dump($request->path());
        dump($request->pathinfo());
        dump($request->domain());

        #请求类型
        dump($request->method());
        dump($request->isGet());
        dump($request->isPost());
        dump($request->isAjax());

        #请求参数
        dump($request->get());
        dump($request->post());
        dump($request->param());
        //session('name','aaa');
        dump($request->session());
        //cookie('email','bbb');
        dump($request->cookie());

        #获取模块 控制器 操作
        dump($request->module());
        dump($request->controller());
        dump($request->action());

        dump($request->url());
        dump($request->baseUrl());

        #input助手函数
        //获取post传参
        //键名,默认值，强制转换类型
        input('post.id','默认值','intval');
        //获取get传参
        input('get.id','默认值','intval');
    }

    public function rsp(){
        $res = [
            'code'      =>200,
            'result'    =>[
                'list'=>[1,2,3,4,5],
            ],
        ];

        return $res;
    }
}
